﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using YTCMS.Core;
using YTCMS.Services.Services;

namespace App.Areas.Wap.Controllers
{
    public class ProductsController : Controller
    {
        private readonly IcategoryService _category;
        private readonly IproductsService _product;
        public ProductsController(IcategoryService category, IproductsService product)
        {
            this._category = category;
            this._product = product;
        }
        //
        // GET: /Wap/Products/
        public ActionResult Index(int? cid)
        {
            var category = _category.Get(s => s.Id == cid);
            ViewBag.cname = category.Name;
            var cc = cid.ToString();
            var model = _product.GetMany(s => s.strcategory.Contains(cc));
            return View(model);
        }

        public ActionResult Add(int cid, int top)
        {
            var model = _product.GetMany(s => s.CategoryId == cid, Order.desc, "Sort");
            model = model.Skip(top).Take(6);
            return PartialView("List", model);
        }

        public ActionResult details(int id)
        {
            var model = _product.Get(s => s.Id == id);
            return View(model);
        }
	}
}